import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            // System.out.println(a + b);
            System.out.println(operation(a, b, c));
        }

//        int a = in.nextInt();
//        int b = in.nextInt();
//        int c = in.nextInt();
//        // System.out.println(a + b);
//        System.out.println(operation(a, b, c));
    }

    public static int operation(int a, int b, int c) {
        int num = Math.min(a, c);
        int score = 0;
        if (num > b) {//o不够用
            score += b;
        } else if (num == b) {
            score += num * 2;
        } else {//y或u不够用
            b -= num;//除去you中的o剩下的o
            score += num * 2;
            if (b > 1) {
                score += b - 1;
            }
        }

        return score;
    }
}